/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.uct.service.plugins  
 */
package com.apache.uct.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.database.constant.SystemTools;
import com.apache.database.db.IDao;
import com.apache.database.model.MethodParam;
import com.apache.uct.common.entity.Act;

/**
 * description:  获取机构下的指定权限项插件实现
 * @author dwusoft 创建时间：2015-3-17  
 * @Copyright(c)2014:北京--软件技术有限公司
 */
public class FindActForOrgPlugins implements PluginConnector {

	private IDao actDao;

	/**
	 * TODO 获取机构下的指定权限项 
	 */
	public Object execute(ParamsVo vo) throws Exception {
		Act actVo = (Act) vo.getObj();
		String orgId = String.valueOf(vo.getParams("userOrgId"));
		String isSysUser = String.valueOf(vo.getParams("sysUser"));
		String fatherId = actVo.getFatherId();
		if (!"1".equals(isSysUser) && "1".equals(SystemTools.getInstance().getValue("org_act_switch"))) {//机构用户
			MethodParam param = new MethodParam("ByFatherIdAndObjId", "", actDao.getSql(4), Act.class.getName());
			param.setParams("giveType", "org");
			param.setParams("roleId", orgId);
			param.setParams("fatherId", fatherId);
			return actDao.select(param);
		} else {
			MethodParam param = new MethodParam("ByProperty", "", actDao.getSql(3), Act.class.getName());
			param.setParams("fatherId", fatherId);
			return actDao.select(param);
		}
	}

	public void setActDao(IDao actDao) {
		this.actDao = actDao;
	}

}
